﻿// FileManagerDlg.h: 头文件
//

#pragma once
#include <stack>
#include <vector>
struct CFileInfo {
	//是否是文件夹
	BOOL m_bIsDir = FALSE;
	int m_iconIndex;
	CString m_filePath;
	CString m_fileName;
	CString m_fileModifyDate;
	CString m_fileType;
	UINT m_fileSize;
};
// CFileManagerDlg 对话框
class CFileManagerDlg : public CDialogEx {
	// 构造
public:
	CFileManagerDlg(CWnd* pParent = nullptr);	// 标准构造函数
	~CFileManagerDlg();
	// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_FILEMANAGER_DIALOG };
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV 支持

	// 实现
protected:
	HICON m_hIcon;

	// 生成的消息映射函数
	virtual BOOL OnInitDialog();
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	void RetrieveFolderContents(const CString& path);
	void ShowFileList(const CString path);

	HANDLE m_hThread;  // 用于显示文件列表的线程句柄
	void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	void OnEnReturnEditFilePath();
	DECLARE_MESSAGE_MAP()
public:

	CString m_currentPath;

	CEdit m_filePathEdit;
	std::stack<CString> m_historyStack;

	int m_nSortColumn;
	bool m_bSortAscending;
	afx_msg void OnBnClickedButtonBack();
	afx_msg void OnBnClickedButtonParent();
	afx_msg void OnBnClickedButtonFolder();
	void OpenItem(const CString& path);
	CString CFileManagerDlg::BrowseDir(const TCHAR* szTitle, const TCHAR* pszInitPath, CWnd* pParent);
	afx_msg void OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnLvnColumnclickList(NMHDR* pNMHDR, LRESULT* pResult);
	void UpdateFileInfoOrder();
	static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
	afx_msg void OnEnChangeEditFilepath();
	afx_msg void OnLvnItemchangedList(NMHDR* pNMHDR, LRESULT* pResult);
};
